import { BroadCastCall } from "../../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SGroup } from "../../../../../Message/Public/SGroup";
import { GroupUtil } from "../../../view/group/GroupUtil";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../../mvc/ServerCommand";
import { SPublicMiniPlayer } from "../../../../../Message/Public/SPublicMiniPlayer";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { MsgManager } from "../../../manager/MsgManager";
import { Language } from "../../../../../extend/language/Language";
//class CrossGroupInfoCommand
    
    export  class CrossGroupInfoCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc1=null;
            var loc2=null;
            var loc6=null;
            var loc7=null;
            var loc8=false;
            super.call(arg1);
            loc1 = arg1.messageBase as SGroup;
            loc2 = _cache.crossGroup.players;
            var loc3=GroupUtil.getMiniPlayers(loc1.players);
            _cache.crossGroup.waitingPlayers = loc1.players;
            _cache.crossGroup.players = loc3;
            _cache.crossGroup.captain = loc1.captainId;
            _cache.crossGroup.allocation = loc1.allocation;
            _cache.crossGroup.groupId = loc1.groupId;
            _cache.crossGroup.memberInvite = loc1.memberInvite;
            NetDispatcher.dispatchCmd(ServerCommand.CrossGroup_PlayerInfoChange, _cache.crossGroup.players);
            if (loc2.length == 0 && loc3.length > 0) 
            {
                NetDispatcher.dispatchCmd(ServerCommand.CrossGroup_EnterOrLeaveGroup, null);
            }
            var loc4=0;
            var loc5=0;
            loc4 = 0;
            while (loc4 < loc3.length) 
            {
                (loc6 = loc3[loc4] as SPublicMiniPlayer).online = 1;
                loc8 = false;
                loc5 = 0;
                while (loc5 < loc2.length) 
                {
                    loc7 = loc2[loc5] as SPublicMiniPlayer;
                    if (EntityUtil.equal(loc6.entityId, loc7.entityId)) 
                    {
                        loc8 = true;
                        loc2.splice(loc5, 1);
                    }
                    ++loc5;
                }
                if (!loc8) 
                {
                    MsgManager.showRollTipsMsg(Language.getStringByParam(62310, loc6.name));
                }
                ++loc4;
            }
            return;
        }
    }
